import {resolve} from 'path';
import {defineConfig, loadEnv} from 'vite';
import postCssPxToRem from "postcss-pxtorem"
import vue from '@vitejs/plugin-vue';

function pathResolve(dir: string): string {
    return resolve(process.cwd(), '.', dir)
};
export default ({mode}) => defineConfig({
    plugins: [vue()],
    css: {
        postcss: {
            plugins: [
                postCssPxToRem({
                    rootValue: 75, // 设计稿尺寸 1rem大小
                    propList: ['*',"!border"], // 需要转换的属性，这里选择全部都进行转换
                    selectorBlackList: [".el-"] // 过滤掉.el-开头的class，不进行rem转换
                })
            ]
        },
    },
    define: {
        'process.env': loadEnv(mode, process.cwd())
    },
    resolve: {
        alias: {
            '@': pathResolve('src')
        }
    },
    server: {
        port: 9000,
        proxy: {
            // 选项写法
            '/api': {
                target: 'http://47.251.22.217:8601',
                changeOrigin: true
            }
        },
        hmr: {
            overlay: false
        },
        host: '0.0.0.0'
    },
    base:'./'
})
